package com.dwb.controller;
import com.dwb.entity.SOrder;
import com.dwb.result.Result;
import com.dwb.service.SOrderService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
 * @Author manke
 * @Date 2020/6/27 14:57
 * @Version 0.0.1
 */
@Api(value = "SOrder",description = "订单控制器")
@RestController
@RequestMapping("/SOrder")
public class SOrderController {
    @Autowired
    private SOrderService sOrderService;

    /**
     * 更改订单状态
     * @param parameters
     * @return
     */
    @PostMapping("/updateState")
    @ApiOperation(value = "updateState",notes = "更新订单状态")
    public Result<String> updateState(@RequestBody Map<String,Object> parameters){
        Result<String> result = Result.newSuccess();
        sOrderService.update(parameters);
//        result.setDataMap(result);
        return result;
    }

    /**
     * 获取订单列表
     * @param parameters
     * @return
     */
    @PostMapping("/getList")
    @ApiOperation(value = "getList",notes = "获取订单列表")
    public Result<PageInfo<SOrder>> getList(@RequestBody Map<String ,String> parameters){
        Result<PageInfo<SOrder>> result = Result.newSuccess();
        PageInfo<SOrder> list = sOrderService.getList(parameters);
        result.setDataMap(list);
        return result;

    }
    /**
     * 获取订单详情
     * @param parameters
     * @return
     */
    @PostMapping("/getInfo")
    @ApiOperation(value = "getInfo",notes = "获取订单详情")
    public Result<Map<String,Object>> getInfo(@RequestBody Map<String,Object> parameters){
        Result<Map<String,Object>> result = Result.newSuccess();
        Map<String,Object> map = sOrderService.getInfo(parameters);
        result.setDataMap(map);
        return result;
    }

}
